<?php
/**
 * +----------------------------------------------------------------------
 * | Author: 罗极
 * +----------------------------------------------------------------------
 * | Description: ViewConfig.php
 * +----------------------------------------------------------------------
 * | User: Administrator Date: 8/21/ 0021 Time: 17:44
 * +----------------------------------------------------------------------
 */
namespace Framework\View;

class ViewConfig
{
    public static $entryDirName;

    public static $moduleDirName;

    public static $viewDirName;

    public static $controllerName;

    public static $actionName;

    public static $suffix;


    public static function getViewPath(string $custom = '') : string
    {
        defined('DS') or define('DS', DIRECTORY_SEPARATOR);

        if(!empty($custom)) {
            return self::$entryDirName.DS.
                   self::$moduleDirName.DS.
                   self::$viewDirName.DS.
                   self::$controllerName.DS.
                   self::parserName($custom).'.'.self::$suffix;
        } else {
            return  self::$entryDirName.DS.
                    self::$moduleDirName.DS.
                    self::$viewDirName.DS.
                    self::$controllerName.DS.
                    self::parserName(self::$actionName).
                    '.'.self::$suffix;
        }
    }

    public static function parserName(string $name) : string
    {
        $name = preg_replace('/([A-Z])/','_$1',$name);
        $name = ltrim($name, '_');
        $name = strtolower($name);
        return $name;
    }



}